#ifndef AVALON_GROUPCONNECTION_HPP
#define AVALON_GROUPCONNECTION_HPP
#include <vector>
#include <boost/signals2.hpp>
#include "Avalon/SignalHandling/SignalHandling.hpp"

namespace Avalon {
namespace SignalHandling {

  /*! \class GroupConnection
   *  \brief Aggregates individual connections together.
   */
  class GroupConnection {
    public:

      //! Constructs a GroupConnection.
      GroupConnection();

      //! Constructs a GroupConnection from a list of connections.
      /*!
        \param connections The list of connections to group together.
      */
      GroupConnection(
        const std::vector<boost::signals2::connection>& connections);

      //! Constructs a GroupConnection from a single connection.
      /*!
        \param connection The individual connection in the group.
      */
      GroupConnection(const boost::signals2::connection& connection);

      //! Constructs a GroupConnection from a collection of connection.
      /*!
        \param connection0 A connection in the group.
        \param connection1 A connection in the group.
      */
      GroupConnection(const boost::signals2::connection& connection0,
        const boost::signals2::connection& connection1);

      //! Constructs a GroupConnection from a collection of connection.
      /*!
        \param connection0 A connection in the group.
        \param connection1 A connection in the group.
        \param connection2 A connection in the group.
      */
      GroupConnection(const boost::signals2::connection& connection0,
        const boost::signals2::connection& connection1,
        const boost::signals2::connection& connection2);

      //! Constructs a GroupConnection from a collection of connection.
      /*!
        \param connection0 A connection in the group.
        \param connection1 A connection in the group.
        \param connection2 A connection in the group.
        \param connection3 A connection in the group.
      */
      GroupConnection(const boost::signals2::connection& connection0,
        const boost::signals2::connection& connection1,
        const boost::signals2::connection& connection2,
        const boost::signals2::connection& connection3);

      //! Assigns a GroupConnection to this.
      /*!
        \param rhs The right hand side of the assignment.
        \return A reference to this.
      */
      GroupConnection& operator =(const GroupConnection& rhs);

      //! Returns the list of connections in this group.
      const std::vector<boost::signals2::connection>& GetConnections() const;

      //! Swaps the contents of this GroupConnection with another.
      /*!
        \param group The GroupConnection to swap contents with.
      */
      void Swap(GroupConnection& group);

      //! Disconnects all connections.
      void Disconnect();

    private:
      std::vector<boost::signals2::connection> m_connections;
  };

  //! Swaps two GroupConnections.
  /*!
    \param a One of the GroupConnection's to swap.
    \param b The GroupConnection to swap with.
  */
  void swap(GroupConnection& a, SignalHandling::GroupConnection& b);
}
}

namespace std {
  template<> void swap(Avalon::SignalHandling::GroupConnection& a,
    Avalon::SignalHandling::GroupConnection& b);
}

#endif // AVALON_SIGNALCONNECTION_HPP
